/**
 * 所有组件的基类
 * 实现android端物理返回键的监听
 */
import React, { Component } from 'react';
import {
    BackHandler,
    Platform,
} from 'react-native';

export default class BaseComponent extends Component {

    constructor(props) {
        super(props);
    }
    UNSAFE_componentWillMount() {
        if (Platform.OS === 'android') {
            BackHandler.addEventListener("hardwareBackPress", this.onBackClicked);
        }
    }

    componentWillUnmount() {
        if (Platform.OS === 'android') {
            BackHandler.removeEventListener("hardwareBackPress", this.onBackClicked);
        }
        // }else {
        //     this.propstManger.addLengeData(this.props.navigator.getCurrentRoutes().length);
        // }
    }

    //返回 ;//return  true 表示返回上一页  false  表示跳出RN
    onBackClicked = () => { // 默认 表示跳出RN
        return false;
    }

}